import { http } from "@/utils/http";

/** 调整用户积分（增加或减少） */
export const adjustUserPoints = (
  userId: number,
  params: {
    amount: number;
    description: string;
  }
) => {
  return http.request<any>("post", `/api/admin/points/${userId}/points`, {
    params
  });
};
/** 获取指定用户的积分变动记录，包含完整信息（描述、订单号、变动前后余额、状态等） */
export const getUserPointsRecords = (
  userId: number,
  params: {
    page: number;
    size: number;
    type?: string;
    startDate?: string;
    endDate?: string;
    timeUnit?: string;
  }
) => {
  return http.request<any>("get", `/api/admin/points/users/${userId}/records`, {
    params
  });
};
// 获取系统所有用户的积分变动记录，包含完整信息（描述、订单号、变动前后余额、状态等）
export const getAllPointsRecords = (params: {
  userId?: number | string;
  page: number;
  size: number;
  type?: string;
  startDate?: string;
  endDate?: string;
  timeUnit?: string;
}) => {
  return http.request<any>("get", `/api/admin/points/records`, {
    params
  });
};
// 获取积分统计信息
export const getPointsStats = (params: {
  startDate?: string;
  endDate?: string;
  timeUnit?: string;
}) => {
  return http.request<any>("get", `/api/admin/points/stats`, {
    params
  });
};
